package com.tinno.chargelauncher.utils;

import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.BatteryManager;
import android.util.Log;

public class BatteryUtils {

	private static final String  TAG = BatteryUtils.class.getSimpleName();

	public static int getCurrentLevel(Context context){
		IntentFilter filter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
		Intent batteryStatus = context.registerReceiver(null, filter);

		int level = batteryStatus.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);
		int scale = batteryStatus.getIntExtra(BatteryManager.EXTRA_SCALE, -1);

		Log.d(TAG, "getCurrentLevel: level: " + level  + "   scale: " + scale);

		return level;
	}
}
